<template>
  <div>
    <Views ref="prop" v-bind="propsList" @CurrentChange="CurrentChange" @SizeChange="SizeChange" ></Views>
  </div>
</template>

<script>
  import Views from '../../components/common/View'
  import {getUser} from "../../network/UserInfo";
  import {getLog} from "../../network/Log";

  export default {
    name: "log",
    components: {Views},
    data() {
      return {
        /**
         * 传入子组件属性
         */
        propsList: {
          isAllowOperate: false,
          // 面包屑显示
          header1: '首页',
          header1Path: '/welcome',
          header2: '日志记录',
          header2Path: '/log',
          // 表单数据
          tableData:  [],
          /**
           *  单表头显示
           *  prop 表单数据的变量名
           *  label 表头显示名字
           */
          titleNames: [
            {
              prop: 'id',
              label: 'id'
            },
            {
              prop: 'operator',
              label: 'operator'
            },
            {
              prop: 'action',
              label: 'action'
            },
            {
              prop: 'ip',
              label: 'ip'
            },
            {
              prop: 'time',
              label: 'time'
            },
          ],
          // 总页数
          page_total: 0,
          // 分页请求的初始数据
          page: {
            pageNo: 1,
            pageSize: 5
          },
        }
      }
    },
    methods: {
      // 请求数据并刷新
      getData() {
        getLog(this.propsList.page).then(res => {
              console.log(res);
              // 数据传入
              this.propsList.tableData = res.data.content
              // 总页数传入
              this.propsList.page_total = res.data.totalElements
            },
            err => {
              console.log(err);
            })
      },
      // 监听子组件刷新事件
      CurrentChange(e) {
        this.propsList.page.pageNo = e
        this.getData()
      },
      SizeChange(e) {
        this.propsList.page.pageSize = e
        this.getData()
      },
    },
    // 启动触发方法
    mounted() {
      // 父组件触发子组件方法
      this.getData()
    }
  }
</script>

<style scoped>

</style>
